import allure
import logging
from utils.ocr_utils import *
import os

@allure.step("1.请求数据解析")
def analyse_case(case):
    request_data = {
        "method": case["method"],
        "url": os.environ["URL"] + case["url"],
        "params": eval(case["params"]) if isinstance(case["params"], str) else None,
        "data": eval(case["data"]) if isinstance(case["data"], str) else None,
        "json": eval(case["json"]) if isinstance(case["json"], str) else None,
        "files": eval(case["files"]) if isinstance(case["files"], str) else None,
        "headers": eval(case["headers"]) if isinstance(case["headers"], str) else None,
    }

    logging.info(f"1.解析请求数据, 请求数据为: {request_data}")
    allure.attach(f"{request_data}", name="解析数据结果")
    return request_data